﻿using System;

namespace Model
{
    /// <summary>
    /// 生成全局唯一ID
    /// </summary>
    public static class IDGenerater
    {
        private static readonly long Tseed=new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks;
        private static ushort value;

        public static long GenerateId()
        {
            long id = ((DateTime.UtcNow.Ticks - Tseed) / 10000000) << 16;
            return ((DateTime.UtcNow.Ticks - Tseed) / 10000000) << 16 + ++value;
        }
    }
}
